package time.after.time.web.pro;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springside.modules.utils.web.struts2.Struts2Utils;

import time.after.time.entity.pro.City;
import time.after.time.entity.pro.Info;
import time.after.time.service.pro.CityManager;
import time.after.time.service.pro.InfoManager;
import time.after.time.web.BaseActionSupport;


public class InfoAction extends BaseActionSupport {
	
	private static final long serialVersionUID = 38521935045340162L;
	private String province;
	private String infoType;
	private String info;
	private String city;
	private String name;
	private Info info2;
	private List<Info> list;
	private List<City> list2;
	private City city2;
	private List<City> list3;
	
	
	@Autowired
	private InfoManager infoManager;
	
	@Autowired
   private CityManager cityManager;
	
	@Override
	public String execute() {
		 list2=infoManager.selectCity();
		list = infoManager.select();
		return SUCCESS;
	}
	
	public String addInfo() {
		info2 = new Info();
		info2.setInfoType(infoType);
		info2.setProvince(province);
		info2.setInfo(info);
		info2.setCity(city);
		info2.setUserId(1);
		infoManager.save(info2);
		Struts2Utils.renderJson(new time.after.time.sys.utils.Result(200, "ok"));
		return null;
	}

	public void delInfo() {
		String id = request.getParameter("id");
		long ID = Long.parseLong(id);
		infoManager.delete(ID);
		Struts2Utils.renderJson(new time.after.time.sys.utils.Result(200));
	}
	
	public List<City> selectProvince(){	
		city2=new City();
		city2.setName(name);
		list3=cityManager.selectProvince(city2);
		Struts2Utils.renderJson(new time.after.time.sys.utils.Result(200,"ok", list3));
		return null;
		
	}
	
	public void setCity2(City city2) {
		this.city2 = city2;
	}

	public List<City> getList2() {
		return list2;
	}

	public void setList2(List<City> list2) {
		this.list2 = list2;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public void setName(String name) {
		this.name = name;
	}

	
	public List<Info> getList() {
		return list;
	}
	public void setList(List<Info> list) {
		this.list = list;
	}

	public void setInfo2(Info info2) {
		this.info2 = info2;
	}

	public void setInfo(String info) {
		this.info = info;
	}

	public void setInfoType(String infoType) {
		this.infoType = infoType;
	}
	public void setCity(String city) {
		this.city = city;
	}
	
	public List<City> getList3() {
		return list3;
	}

	public void setList3(List<City> list3) {
		this.list3 = list3;
	}
}
